package com.bwie.controller;

import com.bwie.common.domain.Menu;
import com.bwie.common.domain.request.UserReq;
import com.bwie.common.domain.response.UserResp;
import com.bwie.common.result.Result;
import com.bwie.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @className: UserController
 * @Description: TODO
 * @version: v1.８.0
 * @author: GONGWENXUE
 * @date: 2025/10/22 9:28
 */
@CrossOrigin
@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    UserService userService;
    /**
     * 用户密码登录
     */
    @PostMapping("userLogin")
    public Result<UserResp> userLogin(@RequestBody UserReq userReq){
       UserResp userResp= userService.userLogin(userReq);
       return Result.success(userResp);
    }

    /**
     * 手机号密码登录
     * @param userReq
     * @return
     */
    @PostMapping("users")
    public Result<UserResp> userPhone(@RequestBody UserReq userReq){
        UserResp userResp=userService.userPhone(userReq);
        return Result.success(userResp);
    }
    /**
     * 获取验证码
     */
    @GetMapping("getCode/{phone}")
    public Result getCode(@PathVariable("phone") String phone){
        userService.getCode(phone);
        return Result.success();
    }
    /**
     * 菜单树
     */
    @GetMapping("getMenu")
    public Result<List<Menu>> getMenu(){
        List<Menu> menus=userService.getMenu();
        return Result.success(menus);
    }
}
